package anc.tankshooter.controls;

import org.andengine.entity.Entity;
import org.andengine.entity.primitive.Rectangle;
import org.andengine.entity.text.Text;
import org.andengine.util.color.Color;

import anc.server.tankshooter.models.Account;
import anc.tankshooter.ui.ResourcesManager;

public class MatchInfoBoard extends Entity {
	
	private Account mMyAccount,mCompetitorAccount;
	private int mCompetitorHeart;
	private int mMyHeart;
	
	private Rectangle mBackgroudRect;
	private Text mInfoText;
	
	public MatchInfoBoard(Account acc,Account cacc, float x,float y){
		super(x, y);
		setZIndex(1);
		mBackgroudRect = new Rectangle(0, 0,100,50, ResourcesManager.getInstance().mVertexManager);
		mBackgroudRect.setColor(Color.BLACK);
		mBackgroudRect.setAlpha(0.5f);
		
		mInfoText = new Text(5,5,ResourcesManager.getInstance().mWhiteFont18,"",256, ResourcesManager.getInstance().mVertexManager);

		attachChild(mBackgroudRect);
		attachChild(mInfoText);

		mMyAccount = acc;
		mCompetitorAccount = cacc;
	}
	@Override
	protected void onManagedUpdate(float pSecondsElapsed) {
		
		mInfoText.setText(mMyAccount.getUsername()+": "+mMyHeart+"\n"+
				mCompetitorAccount.getUsername() +": "+mCompetitorHeart);
		mBackgroudRect.setSize(mInfoText.getWidth()+10, mInfoText.getHeight()+10);
		super.onManagedUpdate(pSecondsElapsed);
	}

	
	public int getCompetitorHeart() {
		return mCompetitorHeart;
	}
	public void setCompetitorHeart(int mScore) {
		this.mCompetitorHeart = mScore;
	}
	public int getMyHeart() {
		return mMyHeart;
	}
	public void setMyHeart(int mHeart) {
		this.mMyHeart = mHeart;
	}
}
